<?php
/**
 * Created by PhpStorm.
 * User: 图图
 * Date: 2021-6-8
 * Time: 16:29
 */

namespace app\api\controller;

use app\common\controller\Api;
use app\common\model\Area;
use app\common\model\Factor;
use app\common\model\Fenorder;
use app\common\model\Order as OrderModel;
use app\common\model\Goods;
use app\api\controller\Express;
use think\Db;
use app\common\controller\Alipay;

/**
 * 前台首页控制器
 * @package app\index\controller
 */
class OrderRule extends Auth
{
    public $noNeedLogin = [];

    /**
     * 获取服务项目分类
     */
    public function getProjectCate(){
        if($this->request->isPost()){
            $userInfo = $this->userInfo;
            $data = Db::name('qt_project_category')
                ->field('id,name')
                ->where(['store_id'=>$userInfo['store_id']])
                ->order('sort asc')
                ->select();
            $this->result('查询成功',$data,200);
        }
        $this->result('无效的请求','',204);
    }


    /**
     * 查询所有项目和指定分类项目
     */
    public function getProject(){
        if($this->request->isPost()){
            $userInfo = $this->userInfo;
            $getData  =$this->request->post();

            if(empty($getData['category_id'])){
                //全部项目
                $data = Db::name('qt_project')
                    ->field('id,name,price')
                    ->where(['store_id'=>$userInfo['store_id'],'status'=>'1'])
                    ->select();
            }else{
                //筛选项目
                $data = Db::name('qt_project')
                    ->field('id,name,price')
                    ->where(['store_id'=>$userInfo['store_id'],'status'=>'1','project_category_id'=>$getData['category_id']])
                    ->select();
            }
            $this->result('查询成功',$data,200);
        }
        $this->result('无效的请求','',204);
    }


    /**
     * 获取手牌
     * @return array
     */
    public function getCashier()
    {
        if($this->request->isPost()){
            $data = Db::name('qt_hand_card')
                ->field('id,name')
                ->where(['status'=>'2'])
                ->order('sort asc')
                ->select();
            $this->result('请求成功',$data,200);
        }
        $this->result('无效的请求','',204);
    }

    /**
     * 获取轮排数据
     * @param $sex
     * @param $projectType
     */
    public function takeTurns($sex,$projectType){

    }

}
